package com.jkc.xh.adapters.viewholder;

import android.content.Context;
import android.util.AttributeSet;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.jkc.xh.R;
import com.jkc.xh.models.FavModel;

import org.androidannotations.annotations.EViewGroup;
import org.androidannotations.annotations.ViewById;

/**
 * Created by wangjie28 on 2015/11/13.
 */
@EViewGroup(R.layout.item_my_choose)
public class MyChooseItemView extends RelativeLayout {

    @ViewById
    TextView stock_name;
    @ViewById
    TextView stock_code;
    @ViewById
    TextView last_price;
    @ViewById
    TextView incr_percent;

    public MyChooseItemView(Context context) {
        super(context);
    }

    public MyChooseItemView(Context context, AttributeSet attrs) {
        super(context, attrs);
    }


    public void bind(FavModel model) {
        stock_name.setText(model.stock_name);
        stock_code.setText(model.stock_code);
        last_price.setText(model.last_price);
        incr_percent.setText(model.incr_percent);

        if (model.isProfit()) {
            setAllTextColor(getResources().getColor(R.color.text_color_red));
        } else {
            setAllTextColor(getResources().getColor(R.color.text_color_blue));
        }
        if (model.isStop()) {
            setAllTextColor(getResources().getColor(R.color.text_color_gray));
        }
    }


    private void setAllTextColor(int textColorId) {
        stock_name.setTextColor(textColorId);
        stock_code.setTextColor(textColorId);
        last_price.setTextColor(textColorId);
        incr_percent.setTextColor(textColorId);
    }
}
